package com.ws.controller;

import com.ws.bean.Themes;
import com.ws.service.ThemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/theme")
public class ThemeController {
    @Autowired
    ThemeService themeService;

    @RequestMapping("list")
    public String list(Model model) {
        List<Themes> list = themeService.list();
        model.addAttribute("list",list);
        return "theme/list";
    }

    // 跳转到添加页面
    @RequestMapping("toAdd")
    public String toAdd() {
        return "theme/add";
    }
    @RequestMapping("add")
    public String add(Themes themes) {
        themeService.add(themes);
        return "redirect:/theme/list";
    }
    // 删除
    @RequestMapping("delete")
    public String delete(Integer id) {
        themeService.delete(id);
        return "redirect:/theme/list";
    }
}
